package net.dengzixu.java.homework.period9;

/**
 * @author Deng Zixu <admin@dengzixu.com>
 */
public class Period9Homework5 {
    public static void main(String[] args) {

        for (int i = 100; i < 1000; i++) {
            if (isNarcissisticNumber(i)) {
                System.out.println(i + " 是水仙花数");
            }
        }
    }

    public static boolean isNarcissisticNumber(int num) {
        int fNumber, sNumber, tNumber;
        fNumber = num % 10;
        sNumber = num % 100 / 10;
        tNumber = num / 100;


        int cubNum = (int) Math.pow(fNumber, 3);
        cubNum += Math.pow(sNumber, 3) + Math.pow(tNumber, 3);

        return cubNum == num;
    }
}
